concatMap (\(t, l) -> map (t,) l) regions
where
regions =
- [ ("US East (N. Virginia)", [S3Region "US", GlacierRegion "us-east-1"])
- , ("US West (Oregon)", [BothRegion "us-west-2"])
+ -- Based on the list at https://docs.aws.amazon.com/general/latest/gr/s3.html
+ [ ("US East (Ohio)", [S3Region "us-east-2"])
+ , ("US East (N. Virginia)", [S3Region "US", GlacierRegion "us-east-1"])
, ("US West (N. California)", [BothRegion "us-west-1"])
- , ("EU (Ireland)", [S3Region "EU", GlacierRegion "eu-west-1"])
+ , ("US West (Oregon)", [BothRegion "us-west-2"])
+ , ("Africa (Cape Town)", [S3Region "af-south-1"])
+ , ("Asia Pacific (Hong Kong)", [S3Region "ap-east-1"])
+ , ("Asia Pacific (Hyderabad)", [S3Region "ap-south-2"])
+ , ("Asia Pacific (Jakarta)", [S3Region "ap-southeast-3"])
+ , ("Asia Pacific (Malaysia)", [S3Region "ap-southeast-5"])
+ , ("Asia Pacific (Melbourne)", [S3Region "ap-southeast-4"])
+ , ("Asia Pacific (Mumbai)", [S3Region "ap-south-1"])
+ , ("Asia Pacific (Osaka)", [S3Region "ap-northeast-3"])
+ , ("Asia Pacific (Seoul)", [S3Region "ap-northeast-2"])
, ("Asia Pacific (Singapore)", [S3Region "ap-southeast-1"])
- , ("Asia Pacific (Tokyo)", [BothRegion "ap-northeast-1"])
, ("Asia Pacific (Sydney)", [S3Region "ap-southeast-2"])
+ , ("Asia Pacific (Taipei)", [S3Region "ap-east-2"])
+ , ("Asia Pacific (Thailand)", [S3Region "ap-southeast-7"])
+ , ("Asia Pacific (Tokyo)", [BothRegion "ap-northeast-1"])
+ , ("Canada (Central)", [S3Region "ca-central-1"])
+ , ("Canada West (Calgary)", [S3Region "ca-west-1"])
+ , ("EU (Frankfurt)", [BothRegion "eu-central-1"])
+ , ("EU (Ireland)", [S3Region "EU", GlacierRegion "eu-west-1"])
+ , ("Europe (London)", [S3Region "eu-west-2"])
+ , ("Europe (Milan)", [S3Region "eu-south-1"])
+ , ("Europe (Paris)", [S3Region "eu-west-3"])
+ , ("Europe (Spain)", [S3Region "eu-south-2"])
+ , ("Europe (Stockholm)", [S3Region "eu-north-1"])
+ , ("Europe (Zurich)", [S3Region "eu-central-2"])
+ , ("Israel (Tel Aviv)", [S3Region "il-central-1"])
+ , ("Mexico (Central)", [S3Region "mx-central-1"])
+ , ("Middle East (Bahrain)", [S3Region "me-south-1"])
+ , ("Middle East (UAE)", [S3Region "me-central-1"])
, ("South America (São Paulo)", [S3Region "sa-east-1"])
- -- These need signature V4 to be used, and currently v2 is
- -- the default, so to add these would need other changes.
- -- , ("EU (Frankfurt)", [BothRegion "eu-central-1"])
- -- , ("Asia Pacific (Seoul)", [S3Region "ap-northeast-2"])
- -- , ("Asia Pacific (Mumbai)", [S3Region "ap-south-1"])
- -- , ("US East (Ohio)", [S3Region "us-east-2"])
]
fromServiceRegion (BothRegion s) = s
data SignatureVersion
= SignatureVersion Int
+ | DefaultSignatureVersion
| Anonymous
signatureVersionParser :: RemoteConfigField -> FieldDesc -> RemoteConfigFieldParser
signatureVersionParser f fd =
- genParser go f (Just defver) fd
+ genParser go f (Just DefaultSignatureVersion) fd
(Just (ValueDesc "v2 or v4 or anonymous"))
where
go "v2" = Just (SignatureVersion 2)
go "anonymous" = Just Anonymous
go _ = Nothing
- defver = SignatureVersion 2
-
isAnonymous :: ParsedRemoteConfig -> Bool
isAnonymous c =
case getRemoteConfigValue signatureField c of
Nothing
| port == 443 -> AWS.HTTPS
| otherwise -> AWS.HTTP
- cfg = case getRemoteConfigValue signatureField c of
- Just (SignatureVersion 4) ->
- (S3.s3v4 proto endpoint False S3.SignWithEffort)
+ cfg = if usev4 $ getRemoteConfigValue signatureField c
+ then (S3.s3v4 proto endpoint False S3.SignWithEffort)
#if MIN_VERSION_aws(0,24,0)
- { S3.s3Region = r }
+ { S3.s3Region = r }
#endif
- _ -> (S3.s3 proto endpoint False)
+ else (S3.s3 proto endpoint False)
#if MIN_VERSION_aws(0,24,0)
- { S3.s3Region = r }
+ { S3.s3Region = r }
+ -- Use signature v4 for all AWS hosts by default, but don't use it by
+ -- default for other S3 hosts, which may not support it.
+ usev4 (Just DefaultSignatureVersion)
+ | h == AWS.s3DefaultHost = True
+ | otherwise = False
+ usev4 (Just (SignatureVersion 4)) = True
+ usev4 (Just (SignatureVersion _)) = False
+ usev4 (Just Anonymous) = False
+ usev4 Nothing = False
+
r = encodeBS <$> getRemoteConfigValue regionField c
#endif